package com.zte.cl.task;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.zte.cl.service.ContentPageService;
import com.zte.cl.service.SeedPageService;

@Service
public class CrawlTask {

	private static final Log log = LogFactory.getLog(CrawlTask.class);
	
	@Resource
	private SeedPageService seedPageService;
	
	@Resource
	private ContentPageService contentPageService;
	
	/**
	 * 抓取种子页面策略 5-23点，10,30,50分钟执行一次
	 */
	@Scheduled(cron = "0 10,30,50 5-23 * * ? ")
	public void crawlSeedPage() {
		log.info("开始执行抓取种子页面定时任务...");
		seedPageService.execute();
	}
	
	/**
	 * 抓取内容页策略，5-23点, 每分钟的0秒和30秒执行一次
	 */
	@Scheduled(cron = "0,30 * 5-23 * *  ?")
	public void crawlContentPage() {
		log.info("开始执行抓取内容页面定时任务...");
		contentPageService.execute();
	}
}
